<table class="ui celled striped table">
  <thead>
    <tr>
      <th>Author</th>
      <th>News</th>
      <th>Excerpt</th>
      <th>Create Time</th>
      <th>Edit Time</th>
      <th>Approved</th>
      <th></th>
    </tr>
  </thead>

  <tbody>
  <%= for comment <- @comments do %>
    <tr>
      <td>
      <%= if comment.author do %>
        <%= link to: Routes.admin_person_path(@conn, :show, comment.author), title: "Author: #{comment.author.name}", data: [popup: true] do %>
          <img class="ui avatar image" src="<%= PersonView.avatar_url(comment.author) %>">
        <% end %>
      <% else %>
        [deleted]
      <% end %>
      </td>
      <td><%= link(SharedHelpers.truncate(comment.news_item.headline, 50), to: comment.news_item.url, rel: "external") %></td>
      <td><%= comment.content |> SharedHelpers.md_to_text() |> SharedHelpers.truncate(50) %></td>
      <td><%= AdminHelpers.ts(comment.inserted_at) %></td>
      <td><%= AdminHelpers.ts(comment.edited_at) %></td>
      <td class="center aligned">
        <%= if comment.approved do %>
          <i class="green check icon"></i>
        <% else %>
          <i class="red close icon"></i>
        <% end %>
      </td>
      <td class="center aligned">
        <div class="ui small basic buttons">
          <%= AdminHelpers.icon_link("eye", to: permalink(@conn, comment)) %>
          <%= AdminHelpers.icon_link("edit", to: Routes.admin_news_item_comment_path(@conn, :edit, comment)) %>
          <%= AdminHelpers.icon_link("trash", to: Routes.admin_news_item_comment_path(@conn, :delete, comment), method: :delete, data: [confirm: "Are you sure?"]) %>
        </div>
      </td>
    </tr>
  <% end %>
  </tbody>
</table>
